<?php
header("Content-type:Content-type: application/json;charset='utf-8'");
    if ($_POST) {
        include '../../api/config.php';
        include './comm.php';
        $json = $_POST["data"];
        $data = json_decode($json);
        $id = $data->head;
        //系统信息
        if ($id == '1003') {
            $name = $data->name;
            $logo = $data->logo;
            $title = $data->title;
            $url = $data->url;
            $Keywords = $data->Keywords;
            $description = $data->description;
            $beian = $data->beian;
            $flg = $data->status;
            $beizhu = $data->beizhu;
            $ids = $data->Id;
            $sql_3 = "UPDATE sys SET name='{$name}',logo='{$logo}',title='{$title}',url='{$url}',Keywords='{$Keywords}',description='{$description}',beian='{$beian}',flg='{$flg}',beizhu='{$beizhu}' WHERE Id='{$ids}'";
            $myfile = fopen("../../index.html", "w") or die("Unable to open file!");
            $txt = '<!DOCTYPE html>
    <html lang="zh">

    <head>
        <meta charset="UTF-8">
        <meta content="' . $Keywords . '" name="Keywords">
        <meta name="description" content="' . $description . '" />
        <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0, user-scalable=no" />
        <title>' . $title . '</title>
        <link href="https://fonts.googleapis.com/css?family=Inconsolata" rel="stylesheet">
        <link rel="stylesheet" href="https://cdn.bootcss.com/material-design-icons/3.0.1/iconfont/material-icons.css">
        <script src="./common/public.js"></script>
        <link rel="stylesheet" href="./common/m.css">
        <link rel="stylesheet" href="./assets/css/index.css">
    </head>

    <body>

        <div class="box" v-cloak>
            <!-- 导航 -->
            <header>
                <div class="logo">' . $name . '</div>
                <div class="navs">
                    <a :href="item.url" v-for="(item,index) in nav" :key="item.Id" v-cloak>{{item.name}}</a>
                </div>
                <!-- 小屏幕nav -->
                <mu-menu cover placement="bottom-end" :open.sync="open">
                    <mu-button icon>
                        <mu-icon value="menu"></mu-icon>
                    </mu-button>
                    <mu-list slot="content">
                        <mu-list-item button v-for="(item,index) in nav" :key="item.Id" :href="item.url">
                            <mu-list-item-title>
                                {{item.name}}
                            </mu-list-item-title>
                        </mu-list-item>
                    </mu-list>
                </mu-menu>
                <!-- 小屏幕nav -->
            </header>
            <!-- 导航 -->
            <!-- 主体 -->
            <article>
                <section>
                <!-- 通知 -->
                <div class="msg" v-if="msg_data">
                    <ul>
                        <li v-for="(item,index) in msg_data" :key="item.Id">
                            <a :href="item.url" target="_blank">{{item.conts}}</a>
                        </li>
                    </ul>
                </div>
                <!-- 通知 -->
                    <mu-load-more ref="container" @refresh="refresh" :refreshing="refreshing" :loading="loading" @load="load"
                        :loaded-all="loaded_all">
                        <mu-list>
                            <template>
                                <mu-container v-for="(items,index) in item" :key="items.Id">
                                    <mu-card style="width:100%;">
                                        <a :href="items.href" target="_blank">
                                            <mu-card-media>
                                                <img src="" class="img" :data-img="items.book_img">
                                            </mu-card-media>
                                            <mu-card-title :title="items.title" :sub-title="items.timer"></mu-card-title>
                                        </a>
                                        <mu-divider></mu-divider>
                                        <mu-card-actions>
                                            <mu-button flat class="primary" @click.native="like_click(index,items.Id)">
                                                <div class="like">
                                                    <!-- 点赞 -->
                                                </div>
                                            </mu-button>
                                            <mu-button flat @click.native="gift_click(index,items.Id)">
                                                <div class="gift">
                                                    <!-- 打赏 -->
                                                </div>
                                            </mu-button>
                                        </mu-card-actions>
                                    </mu-card>
                                </mu-container>
                            </template>
                        </mu-list>
                    </mu-load-more>
                </section>
                <!-- 侧边 -->
                <aside>
                    <mu-container>
                        <mu-expansion-panel :expand="expands">
                            <div slot="header">标签</div>
                            <mu-button color="primary" v-for="(item,index) in tag" :key="item.Id" v-cloak>{{item.name}}</mu-button>
                        </mu-expansion-panel>
                        <mu-expansion-panel :expand="expands">
                            <div slot="header">爱尚博客小程序</div>
                            <img src="./image/xcx.jpg" alt="爱尚博客小程序">
                        </mu-expansion-panel>
                        <mu-expansion-panel :expand="expands">
                            <div slot="header">最近更新</div>
                            <mu-list>
                                <mu-tooltip :content="set_tips(item.timer,1)" v-for="(item,index) in new_items" :key="item.Id"
                                    placement="top">
                                    <a :href="item.href" target="_blank">
                                        <mu-list-item button :ripple="false">
                                            <mu-list-item-action v-cloak>
                                                {{index+1}}
                                            </mu-list-item-action>
                                            <mu-list-item-title v-cloak>{{item.title}}</mu-list-item-title>
                                        </mu-list-item>
                                    </a>
                                </mu-tooltip>
                            </mu-list>
                        </mu-expansion-panel>
                        <mu-expansion-panel :expand="expands">
                            <div slot="header">查看最多</div>
                            <mu-list>
                                <mu-tooltip :content="set_tips(item.look_num)" v-for="(item,index) in hot_items" :key="item.Id"
                                    placement="top">
                                    <a :href="item.href" target="_blank">
                                        <mu-list-item button :ripple="false">
                                            <mu-list-item-action v-if="index <= 2">
                                                <mu-badge :content="index+1" color="secondary"></mu-badge>
                                            </mu-list-item-action>
                                            <mu-list-item-action v-if="index > 2">
                                                <mu-badge :content="index+1"></mu-badge>
                                            </mu-list-item-action>
                                            <mu-list-item-title v-cloak>{{item.title}}</mu-list-item-title>
                                        </mu-list-item>
                                    </a>
                                </mu-tooltip>
                            </mu-list>
                        </mu-expansion-panel>
                        <mu-expansion-panel :expand="expands">
                            <div slot="header">看个广告</div>
                            <mu-carousel transition="fade" v-if="ad_data">
                                <mu-carousel-item v-for="(item,index) in ad_data" :key="item.Id">
                                    <a :href="item.href">
                                        <img :src="item.ad_img" :alt="item.name">
                                    </a>
                                </mu-carousel-item>
                            </mu-carousel>
                        </mu-expansion-panel>
                    </mu-container>
                </aside>
                <!-- 侧边 -->
                <!-- 底部 -->
                <footer>
                    <div class="link">
                        友情链接：
                        <a :href="item.url" v-for="(item,index) in links" :key="item.Id" :title="item.beizhu" target="_blank">
                            <mu-button color="primary" flat v-cloak>{{item.name}}</mu-button>
                        </a>
                    </div>
                    <div class="footer_bm">
                        <p>
                        ' . $beian . '
                        </p>
                    </div>
                </footer>
                <!-- 底部 -->
            </article>
            <!-- 主体 -->
            <!-- 打赏 -->
            <mu-container v-if="openAlert">
                <mu-dialog title="支持一下下嘛?" width="450" max-width="80%" :esc-press-close="false"
                    :overlay-close="false" :open.sync="openAlert">
                    <img src="./image/3q.png" alt="">
                    <mu-button slot="actions" flat color="primary" @click="closeAlertDialog">考虑一下</mu-button>
                    <mu-button slot="actions" flat color="primary" @click="closeAlertDialog">我不！</mu-button>
                </mu-dialog>
            </mu-container>
            <!-- 打赏 -->
        </div>
    </body>
    <script src="./common/v.js"></script>
    <script src="./common/a.js"></script>
    <script src="./common/m.js"></script>
    <script src="./assets/js/index.js"></script>
    </html>';
            fwrite($myfile, $txt);
            fclose($myfile);
        }
        //保存系统信息
        if ($id == '1003') {
            if (flag($data)) {
                $stmt_3 = $conn->prepare($sql_3);
                $stmt_3->execute();
                echo get_msg('200','更新数据成功~','../index.html',false);
            } else {
                echo get_msg('500','权限不足~','../index.html',false);
            }
        }
        //保存系统信息
        if ($id == '1002') {
            $sql = "SELECT * FROM sys";
            if (flag($data)) {
                $stmt = $conn->query($sql);
                $stmt->execute();
                $result = $stmt->setFetchMode(PDO::FETCH_ASSOC);
                $result = $stmt->fetchAll();
                if ($result) {
                    echo get_msg('200','获取数据成功~',false, $result);
                } else {
                    echo get_msg('400','数据异常~',false,false);
                }
            } else {
                echo get_msg('500','权限不足~','../index.html',false);
            }
            // 输出内容
        }
        $conn = null;
    } else {
        echo "<script>\r\n    window.location.href = '../../';\r\n    </script>";
    }